var provinceArray = [{id:1,name:"四川省"},
    {id:2,name:"湖北省"},
    {id:3,name:"湖南省"},
    {id:4,name:"江苏省"},
    {id:5,name:"浙江省"}];

var cityArray = [{id:1,name:'成都市',proId:1},
    {id:2,name:'绵阳市',proId:1},
    {id:3,name:'德阳市',proId:1},
    {id:4,name:'武汉市',proId:2},
    {id:5,name:'宜昌市',proId:2},
    {id:6,name:'长沙市',proId:3},
    {id:7,name:'张家界',proId:3},
    {id:8,name:'南京市',proId:4},
    {id:9,name:'无锡市',proId:4},
    {id:10,name:'杭州市',proId:5},
    {id:11,name:'金华市',proId:5}];

var proObj,cityObj;
$(function () {
    proObj = $("#province");
    let prostr = "<option value=''>请选择省份</option>";
    for (let i = 0; i < provinceArray.length; i++) {
        let obj = provinceArray[i];
        prostr += `<option value=${obj.id}>${obj.name}</option>`;
    }
    proObj.html(prostr);

    proObj.change(function () {
        choiceCity(proObj.val());
    });
});

function choiceCity(proId) {
    cityObj = $("#cities");
    let str = "";
    for(let i = 0; i < cityArray.length; i++){
        let Obj = cityArray[i];
        if(proId == Obj.proId){
            str += `<option value=${Obj.id}>${Obj.name}</option>`
        }
    }
    cityObj.html(str);
}